﻿namespace _61_WPF调用Java接口
{
    internal class Program
    {
        private static string url = "https://localhost:7054/WeatherForecast";
        private static string url1 = "https://localhost:7054/api/OCSData";
        static void Main(string[] args)
        {
            GetHttpMethod();
            Console.ReadKey();//接口是通用的跨平台
        }

        private static void GetHttpMethod()
        {
            string ret = string.Empty;
            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage httpResponse = client.GetAsync(url1).Result;
                if (httpResponse.IsSuccessStatusCode)
                {
                    ret = httpResponse.Content.ReadAsStringAsync().Result;
                }
            }

        }
    }
}
